using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace ICP_MS.Plugin.Experiment;

public class FormCode : Form
{
	private ExperimentDatas experiment = null;

	private ExperimentDB db = null;

	private IContainer components = null;

	private Label label1;

	private TextBox textBox1;

	private Button button1;

	public void SetParams(ExperimentDatas experiment, ExperimentDB db)
	{
		this.experiment = experiment;
		this.db = db;
	}

	public FormCode()
	{
		InitializeComponent();
	}

	private void button1_Click(object sender, EventArgs e)
	{
		try
		{
			int code = Convert.ToInt32(textBox1.Text);
			if (code == DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day)
			{
				FormBlankCalibration formBlankCalibration = new FormBlankCalibration();
				formBlankCalibration.SetParams(experiment, db);
				formBlankCalibration.ShowDialog();
			}
			else
			{
				MessageBox.Show("密码错误");
			}
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message);
		}
		finally
		{
			Close();
		}
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.label1 = new System.Windows.Forms.Label();
		this.textBox1 = new System.Windows.Forms.TextBox();
		this.button1 = new System.Windows.Forms.Button();
		base.SuspendLayout();
		this.label1.AutoSize = true;
		this.label1.Location = new System.Drawing.Point(64, 28);
		this.label1.Name = "label1";
		this.label1.Size = new System.Drawing.Size(43, 15);
		this.label1.TabIndex = 0;
		this.label1.Text = "密码：";
		this.textBox1.Location = new System.Drawing.Point(113, 28);
		this.textBox1.Name = "textBox1";
		this.textBox1.Size = new System.Drawing.Size(185, 20);
		this.textBox1.TabIndex = 1;
		this.textBox1.UseSystemPasswordChar = true;
		this.button1.Location = new System.Drawing.Point(223, 70);
		this.button1.Name = "button1";
		this.button1.Size = new System.Drawing.Size(75, 23);
		this.button1.TabIndex = 2;
		this.button1.Text = "验证";
		this.button1.UseVisualStyleBackColor = true;
		this.button1.Click += new System.EventHandler(button1_Click);
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(338, 117);
		base.Controls.Add(this.button1);
		base.Controls.Add(this.textBox1);
		base.Controls.Add(this.label1);
		base.Name = "FormCode";
		this.Text = "验证";
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
